package com.cy.pj.goods.service;

import com.cy.pj.goods.dao.GoodsDao;
import com.cy.pj.goods.pojo.Goods;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    private final static Logger log= LoggerFactory.getLogger(GoodsServiceImpl.class);
    @Autowired
    private GoodsDao goodsDao;
    @Override
    public List<Goods> findGoods() {
        long start=System.currentTimeMillis();
        log.info("start:{}",start);
        List<Goods> goods=goodsDao.findGoods();
        long end=System.currentTimeMillis();
        log.info("end:{}",end);
        log.info("cost:{}",end-start);
        return goods;
    }

    @Override
    public int deleteById1(Integer id) {
        long start=System.currentTimeMillis();
        log.info("start:{}",start);
        int result=goodsDao.deleteById1(id);
        long end=System.currentTimeMillis();
        log.info("end:{}",end);
        log.info("cost:{}",end-start);
        return result;
    }

    @Override
    public int deleteById2(Integer... ids) {
        long start=System.currentTimeMillis();
        log.info("start:{}",start);
        int result=goodsDao.deleteById2(ids);
        long end=System.currentTimeMillis();
        log.info("end:{}",end);
        log.info("cost:{}",end-start);
        return result;
    }
}
